package com.justnow.offer;

/**
 * @author justnow
 * Created on 2020-09-11
 * Description
 */
public class LearnFinal {
/*
    作者：胖君
    链接：https://www.zhihu.com/question/31345592/answer/114126087
    来源：知乎
    著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。
*/

    //不可变的String
    public static String appendStr(String s){
        s+="bbb";
        return s;
    }

    //可变的StringBuilder
    public static StringBuilder appendSb(StringBuilder sb){
        return sb.append("bbb");
    }

    public static void main(String[] args){
        //String做参数
        String s=new String("aaa");
        String ns=LearnFinal.appendStr(s);
        System.out.println("String aaa >>> "+s.toString());

        //StringBuilder做参数
        StringBuilder sb=new StringBuilder("aaa");
        StringBuilder nsb=LearnFinal.appendSb(sb);
        System.out.println("StringBuilder aaa >>> "+sb.toString());
    }
}
